package com.cloud.code.牛客网;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Test50 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.nextLine();
            char[] chars = s.toCharArray();

            List<Integer> list = new ArrayList<>();
            int count = 0;
            int pre = -1;
            for (int i = 0; i < chars.length; i++) {

                if (Character.isDigit(chars[i]) && pre == -1) {
                    count++;
                    pre = Character.getNumericValue(chars[i]);
                } else if (Character.isDigit(chars[i]) && pre != -1 && (Character.getNumericValue(chars[i]) - pre == 1 || Character.getNumericValue(chars[i]) == pre)) {
                    pre = Character.getNumericValue(chars[i]);
                    count++;
                    list.add(count);
                } else if(pre != -1){
                    count = 0;
                    pre = -1;

                }

            }

            Collections.sort(list);
            System.out.println(list.get(list.size() - 1));
        }
    }


}
